import { TileLayerOptions, TileLayerMethods, GetTileLayerEventFactory } from './base'
import { TileLayerTDTOptions, TileLayerTDT } from './tdt'
import { TileLayerWMSOptions, TileLayerWMS } from './wms'

export { TileLayerOptions } from './base'
export { TileLayerTDTOptions, TileLayerTDT } from './tdt'
export { TileLayerWMSOptions, TileLayerWMS } from './wms'

/**
 * 自定义的地图图块层事件工厂对象
 */
type TileLayerEventFactory = GetTileLayerEventFactory<TileLayer>

/**
 * 通过此类实现在地图上叠加自定义的地图图块层
 */
export interface TileLayer extends TileLayerMethods {
    readonly options: TileLayerOptions;
    readonly FR: string;

    /**
     * 以指定的参数创建 `TTileLayer` 对象;
     * 这个对象是在地图上叠加栅格地图的时候用到的
     *
     * @param url 图层服务地址
     *
     * @param opts 图层属性对象
     */
    new(url: string, opts: TileLayerOptions): TileLayer;

    /**
     * 添加事件监听函数
     */
    addEventListener: <Event extends keyof TileLayerEventFactory>(event: Event, handler: TileLayerEventFactory[Event]) => void;

    /**
     * 移除事件监听函数
     */
    removeEventListener: <Event extends keyof TileLayerEventFactory>(event: Event, handler: TileLayerEventFactory[Event]) => void
}

export namespace TileLayer {
    export type TDTOptions = TileLayerTDTOptions
    export type TDT = TileLayerTDT

    export type WMSOptions = TileLayerWMSOptions
    export type WMS = TileLayerWMS
}
